package io.jft.doll.room.repository

import io.jft.doll.api.DollApi
import io.jft.doll.api.apiProvider
import io.jft.doll.api.apiProviderMock
import com.g.base.room.repository.BaseRepository
import com.g.base.room.repository.NetworkBoundResult
import com.google.gson.JsonObject

/**
 * Created by G on 2017/12/5 0005.
 */
class DollRepository : BaseRepository() {
    /**
     * 获取别拥有的娃娃
     */
    fun getOtherOwnerDoll(jsonObject: JsonObject) = NetworkBoundResult({ apiProvider.create(DollApi::class.java).getPersonDoll(jsonObject) })

    /**
     * 获取自己拥有的娃娃
     */
    fun getSelfOwnerDoll(jsonObject: JsonObject) = NetworkBoundResult({ apiProviderMock.create(DollApi::class.java).getSelfDoll(jsonObject) })

    /**
     * 获取娃娃详情
     */
    fun getDollDetail(id: String) = NetworkBoundResult({ apiProviderMock.create(DollApi::class.java).getDollDetail(JsonObject().apply { addProperty("id", id) }) })

    /**
     * 兑换娃娃币
     */
    fun dollToCoin(id: String) = NetworkBoundResult({ apiProviderMock.create(DollApi::class.java).dollToCoin(JsonObject().apply { addProperty("id", id) }) })
}
